package main
import "fmt"
//带缓冲信道
func main() {
	ch := make(chan int, 2)
	ch <- 1
	ch <- 2

	// ch <-3
	/*  仅当信道的缓冲区填满后，向其发送数据时才会阻塞。当缓冲区为空时，接收方会阻塞
		fatal error: all goroutines are asleep - deadlock!
		goroutine 1 [chan send]:
		main.main()
			/Users/aurora/Documents/gitee/golang_exercise/basicSytax/src/go_code/chapter05/concurrence/main/demo3.go:9 +0x5c
	*/
	fmt.Println(<-ch)//1
	fmt.Println(<-ch)//2
	fmt.Println(<-ch)
	/*
		fatal error: all goroutines are asleep - deadlock!
		goroutine 1 [chan receive]:
		main.main()
				/Users/aurora/Documents/gitee/golang_exercise/basicSytax/src/go_code/chapter05/concurrence/main/demo3.go:18 +0x125
	*/
}